<template>
  <div class="contributed">
    <el-table :data="list" height="78vh" style="width: 100%"
      ><el-table-column type="index" width="50"> </el-table-column>
      <el-table-column prop="title" label="标题"> </el-table-column>
      <el-table-column prop="browse" label="浏览数" width="100">
      </el-table-column>
      <el-table-column prop="comments" label="评论数" width="100">
      </el-table-column>
      <el-table-column prop="time" label="时间" width="200"> </el-table-column>
      <el-table-column fixed="right" label="操作" width="200">
        <template slot-scope="scope">
          <el-button type="text" class="contributed__item__tools__edit">
            <nuxt-link :to="`/contribution/contribute/${scope.row.id}`"
              ><i class="el-icon-edit iconfont" />编辑
            </nuxt-link></el-button
          >
          <el-button
            type="text"
            icon="el-icon-delete"
            @click="deleteItem(scope.row)"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <Pagination :get-list="getList" :len="len" />
  </div>
</template>

<script>
import Pagination from '@/components/public/pagination'
export default {
  components: { Pagination },
  data() {
    return {
      list: [],
      len: 100
    }
  },
  methods: {
    async getList(page, limit) {
      const { status, data } = await this.$axios.get(
        '/contribution/contributed',
        {
          params: {
            limit,
            page
          }
        }
      )
      if (status === 200 && data.code === 1) {
        this.len = data.len
        this.list = data.data
      }
    },
    deleteItem(row) {
      console.log(row)
    }
  }
}
</script>

<style lang="scss" scoped>
.contributed {
  margin-top: 40px;
}
/deep/ .el-table__body-wrapper {
  @include scroll();
}
</style>
